package com.ruoyi.web.controller.comlbs;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.request.historyvideo.HistoryVideoDeviceCloseParam;
import com.ruoyi.system.domain.request.historyvideo.HistoryVideoDeviceListParam;
import com.ruoyi.system.domain.request.historyvideo.HistoryVideoServiceListParam;
import com.ruoyi.system.service.IHistoryVideoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 描述 历史视频Controller
 * 作者 ZhangPing
 * 创建时间 2023/10/30 14:15
 */
@RestController
@RequestMapping("/comlbs/historyVideo")
public class HistoryVideoController extends BaseController {

    @Autowired
    private IHistoryVideoService historyVideoService;

    @ApiOperation("服务器历史视频列表")
    @PostMapping("/serverList")
    public AjaxResult serverList(@Validated @RequestBody HistoryVideoServiceListParam param) {
        return success(historyVideoService.serverList(param));
    }

    @ApiOperation("设备历史视频列表")
    @PostMapping("/deviceList")
    public AjaxResult deviceList(@Validated @RequestBody HistoryVideoDeviceListParam param) {
        return success(historyVideoService.deviceList(param));
    }

    @ApiOperation("开启设备历史视频")
    @PostMapping("/openDeviceVideo")
    public AjaxResult openDeviceVideo(@Validated @RequestBody HistoryVideoDeviceListParam param) {
        historyVideoService.openDeviceVideo(param);
        return success();
    }

    @ApiOperation(value = "关闭设备历史视频")
    @PostMapping("/closeDeviceVideo")
    public AjaxResult closeDeviceVideo(@Validated @RequestBody HistoryVideoDeviceCloseParam param) {
        historyVideoService.closeDeviceVideo(param);
        return success();
    }

    @ApiOperation(value = "获取历史媒体地址")
    @GetMapping("/getVideoInfo")
    public AjaxResult getVideoInfo(@Validated HistoryVideoDeviceCloseParam param) {
        return success(historyVideoService.getVideoInfo(param));
    }

    @ApiOperation(value = "服务器指定历史视频")
    @PostMapping(value = "/queryTargetHisMedia")
    public AjaxResult queryTargetHisMedia(@RequestBody @Validated HistoryVideoDeviceListParam param) {
        return success(historyVideoService.queryTargetHisMedia(param));
    }


    @ApiOperation(value = "删除服务器指定历史视频")
    @PostMapping(value = "/deleteHisMediaList")
    public AjaxResult deleteHisMediaList(@RequestBody @Validated List<String> rowKeyList) {
        return success(historyVideoService.deleteHisMediaList(rowKeyList));
    }

}
